package com.xhj.mybatis.session;

import com.xhj.mybatis.builder.xml.XMLConfigBuilder;
import com.xhj.mybatis.session.defaults.DefaultSqlSessionFactory;

import java.io.Reader;

/**
 * SqlSessionFactoryBuilder
 *
 * @author XJks
 * @description 构建 SqlSessionFactory 的构建器
 */

public class SqlSessionFactoryBuilder {

    public SqlSessionFactory build(Reader reader) {
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder(reader);
        return build(xmlConfigBuilder.parse());
    }

    public SqlSessionFactory build(Configuration config) {
        return new DefaultSqlSessionFactory(config);
    }
}
